package io.renren.modules.app.constants;

import io.renren.modules.lucky.entity.AppSysOpertionEntity;
import io.renren.modules.lucky.entity.AppSysScoreRuleEntity;
import io.renren.modules.lucky.entity.AppUserScoreEntity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 该静态List用于存放静态数组
 */
public class ListConstants {

    //初始化事件统计数组 容量size：1000
    public static List<AppSysOpertionEntity> analyseList = new ArrayList<AppSysOpertionEntity>(100);

    //初始化积分规则
    public static List<AppSysScoreRuleEntity> ruleList = new ArrayList<>(10);

    public static boolean isWindows() {
        return System.getProperties().getProperty("os.name").toUpperCase().indexOf("WINDOWS") != -1;
    }

    public static AppUserScoreEntity insertScore(String name, int userId){
        AppUserScoreEntity score = new AppUserScoreEntity();
        for (AppSysScoreRuleEntity rule: ListConstants.ruleList){
            Date date = new Date();
            if(name.equals(rule.getRuleType())) {
                score.setCreateTime(date);
                score.setScoreFlag(1);
                score.setScoreName(rule.getRuleDesc());
                score.setScoreNum(rule.getRuleScore());
                score.setUpdateTime(date);
                score.setUserId(userId);
            }
        }
        return score;
    }

}
